From: Matthias Clasen Date: Fri, 12 Aug 2022 16:01:42 +0000 (-0400) Subject: a11y: Fix a memory leak X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~59^2^2~91^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e81db46578590d8130f4d1f63a239baf0f32a9e2;p=gtk4.git a11y: Fix a memory leak We need to free the queued context list in dispose if we didn't get to register the contexts, and we also need to free the list properly when we do get to register them. This showed up in valgrind as leaked GList structs. --- diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c index bffc632c18..1335c7fb24 100644 --- a/gtk/a11y/gtkatspiroot.c +++ b/gtk/a11y/gtkatspiroot.c @@ -106,6 +106,7 @@ gtk_at_spi_root_dispose (GObject *gobject) g_clear_object (&self->cache); g_clear_object (&self->connection); + g_clear_pointer (&self->queued_contexts, g_list_free); G_OBJECT_CLASS (gtk_at_spi_root_parent_class)->dispose (gobject); } @@ -517,7 +518,8 @@ on_registration_reply (GObject *gobject, /* Drain the list of queued GtkAtSpiContexts, and add them to the cache */ if (self->queued_contexts != NULL) { - for (GList *l = g_list_reverse (self->queued_contexts); l != NULL; l = l->next) + self->queued_contexts = g_list_reverse (self->queued_contexts); + for (GList *l = self->queued_contexts; l != NULL; l = l->next) { if (data->register_func != NULL) data->register_func (self, l->data);